Easy2Siksha.com
• Inefficient for large datasets due to 𝑂(𝑛
2
)time complexity.
• Not stable, which can be problematic in certain applications.
Another Example for Clarity
Let’s sort [29, 10, 14, 37, 13].
• Pass 1: Smallest is 10. Swap with 29. → [10, 29, 14, 37, 13]
• Pass 2: Smallest in remaining [29, 14, 37, 13] is 13. Swap with 29. → [10, 13, 14, 37,
29]
• Pass 3: Smallest in [14, 37, 29] is 14. Swap with itself. → [10, 13, 14, 37, 29]
• Pass 4: Smallest in [37, 29] is 29. Swap with 37. → [10, 13, 14, 29, 37]
• Pass 5: Last element already sorted.
Final Sorted List: [10, 13, 14, 29, 37]
Conclusion
Selection Sort is a straightforward algorithm that works by repeatedly selecting the smallest
element and placing it in order. Though not efficient for large datasets, it is an excellent way
to understand the basics of sorting and algorithm design.
SECTION-D
7. Explain the concept of Overloading Member Funcons using suitable example.
Ans: What is Overloading Member Functions?
Overloading member functions means having multiple functions with the same name
inside the same class, but each function works differently because:
They have different number of parameters
Or they have different types of parameters
Or they have different order of parameters
However, they cannot differ only by return type.
In simple words:
Function overloading allows a class to have more than one function with the same name but
different behaviors.